package org.hilo.boot.app.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.context.WebApplicationContext;

/**
 * wrap of SpringBootServletInitializer
 *  
 * @see SpringBootServletInitializer
 * 
 * @author zollty
 * @since 2018-2-28
 */
abstract public class MainBootServletInitializer extends SpringBootServletInitializer {
    
    @Override
    protected SpringApplicationBuilder createSpringApplicationBuilder() {
        return MainApplication.builder();
    }
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(starter());
    }
    
    abstract protected Class<?> starter();
    
    @Override
    protected WebApplicationContext run(SpringApplication application) {
        return (WebApplicationContext) application.run();
    }

}
